import random

def play_game():
    # Set up the boxes with different dollar amounts
    boxes = [10, 20, 500]
    random.shuffle(boxes)

    # Secretly choose which box has the grand prize
    prize_location = boxes.index(500)

    print("====================================")
    print("Welcome to the Three Boxes Game!")
    print("Behind one of these boxes is $500!")
    print("  [Box 1 ]  [Box 2 ]  [Box 3 ]  ")

    choice_text = input("Which box do you choose?(1, 2, or 3):")
    player_choice = int(choice_text) - 1 # Subtract 1 to match list indices

    if player_choice == prize_location:
        print("CONGRATULATIONS! You found the $500!")
    else:
        print("Oh, so close! That box had $" + str(boxes[player_choice]) + " in it.")

        print("Let's see what was in all the boxes...")
        for i in range(3):
            print(f"Box {i+1} had ${boxes[i]}")

while True:
    play_game()
    play_again = input("Do you want to play again? (yes/no): ")
    if play_again != "yes":
        break

print("Thanks for playing!")